<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>JSX - 函数式组件</title> 
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.min.js"></script>
    <style>
      header{
        height: 100px;
        background: #aef;
      }

      main{
        height: 400px;
        background: rgb(86, 118, 148);
      }

      footer{
        height: 100px;
        background: rgb(189, 150, 170);
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      //声明一个类
      //顶部区域组件
      class Top extends React.Component{
        //必须声明一个方法 render   render『渲染』
        render(){
          return <header></header>;
        }
      }

      //内容区组件
      class Content extends React.Component{
        render(){
          return <main></main>;
        }
      }

      //底部区组件
      class Bottom extends React.Component{
        render(){
          return <footer></footer>;
        }
      }

      // <Top></Top> => 内部寻找与 Top 同名的类, 然后『实例化对象』, 调用 render 方法, 得到虚拟 DOM 对象
      //最外层根组件
      class App extends React.Component{
        render(){
          return <div>
                  <Top></Top>
                  <Content />
                  <Bottom />
                </div>
        }
      }

      //渲染
      ReactDOM.render(<App />, document.querySelector('#root'))
    </script>
  </body>
</html>
